Sample Code - Check Method

This sample code shows the use of the Check Method (FormulaFieldDefinition Object). Modify the following sample code to fit your needs.

Private Sub Command1_Click()
On Error GoTo Command1_Click_Error

Dim crystalApplication As CRPEAuto.Application
Dim crystalReport As CRPEAuto.Report
Dim crystalFormFieldDefns As CRPEAuto.FormulaFieldDefinitions
Dim crystalFormFieldDefn As CRPEAuto.FormulaFieldDefinition

Dim strFormulaFieldName As String
Dim strDefinitionName As String
Dim strDefinitionText As String
Dim boolDefinitionCheckFlag As Boolean
Dim strFieldValueType As String

Dim intLoopCount As Integer

Set crystalApplication = CreateObject("Crystal.CRPE.Application")
Set crystalReport = crystalApplication.OpenReport _
    ("d:\crw\reports\craze\wwsales.rpt")

'NOTE : AT THIS POINT IT APPEARS THAT IN THE FOLLOWING YOU MUST USE
' .FormulaFields INSTEAD OF THE DOCUMENTED .FormulaFieldDefinitions

Set crystalFormFieldDefns = crystalReport.FormulaFields

'here we loop through each of the FormulaFieldDefinition records
'pulling out the information we need on a record by record basis
For intLoopCount = 1 To crystalFormFieldDefns.Count
Set crystalFormFieldDefn = crystalFormFieldDefns.Item(intLoopCount)
strFormulaFieldName = crystalFormFieldDefn.FormulaFieldName
strDefinitionName = crystalFormFieldDefn.Name
strDefinitionText = crystalFormFieldDefn.Text
boolDefinitionCheckFlag = crystalFormFieldDefn.Check

Select Case crystalFormFieldDefn.ValueType
'for more information on the list of ValueType values
'please see CRFieldValueType in the VisualBasic Object Browser
Case 7
strFieldValueType = "Number"
Case 8
strFieldValueType = "Currency"
Case 9
strFieldValueType = "Boolean"
Case 10
strFieldValueType = "Date"
Case 11
strFieldValueType = "Time"
Case 12
strFieldValueType = "String"
Case 14
strFieldValueType = "PersistentMemo"
Case 15
strFieldValueType = "BLOB"
Case Else
strFieldValueType = "Unknown"
End Select

Debug.Print "************************************************"
Debug.Print "FormulaDefinition(" + Format(intLoopCount) + ")"
Debug.Print " FormulaFieldName<" + strFormulaFieldName + ">"
Debug.Print " Name<" + strDefinitionName + ">"
Debug.Print " Text<" + strDefinitionText + ">"
Debug.Print " Check<" + Format(boolDefinitionCheckFlag) + ">"
Debug.Print " ValueType<" + strFieldValueType + ">"
Next intLoopCount

Command1_Click_Exit:
Exit Sub

Command1_Click_Error:
If crystalApplication Is Nothing Then
MsgBox "Unable to CreateObject(""Crystal.CRPE.Application"")"
GoTo Command1_Click_Exit
End If
If crystalReport Is Nothing Then
MsgBox "Unable to OpenReport(""d:\crw\reports\craze\wwsales.rpt"")"
GoTo Command1_Click_Exit
End If
MsgBox "Unknown error in Command1_Click routine"
GoTo Command1_Click_Exit
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com